<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>企业用户导入</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../assets/layui/css/layui.css" media="all">
    <link rel="stylesheet" href="../js/formSelects/formSelects-v4.css">
</head>

<body>
<fieldset class="layui-elem-field layui-field-title" style="padding-top: 5px;border: hidden">
    <form class="layui-form" action="" lay-filter="dataForm">
        <div class="layui-form-item layui-col-md11 layui-col-sm11">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <a style="color:#00E4FD" href="company.xlsx" target="_blank">模板下载</a>
            </div>
        </div>
        <div class="layui-form-item layui-col-md11 layui-col-sm11">
            <label class="layui-form-label"><span style="color: red;">*</span>类型选择</label>
            <div class="layui-input-block">
                <input type="radio" name="type" value="all" title="全量导入" checked>
                <input type="radio" name="type" value="add" title="增量导入" >
            </div>
        </div>
        <div class="layui-form-item layui-col-md11 layui-col-sm11">
            <div class="layui-upload">
                <label class="layui-form-label"><span style="color: red;">*</span>文件导入</label>
                <div class="layui-input-block">
                    <button type="button" class="layui-btn" id="file">
                        <i class="layui-icon">&#xe67c;</i>上传
                    </button>
                </div>
            </div>
        </div>
    </form>
</fieldset>
<script src="../assets/layui/layui.js"></script>
<script>
    layui.config({
        base: '../js/'
    })
    layui.use(['form', 'common','upload'], function () {
        var form = layui.form,
                $ = layui.jquery,
                upload = layui.upload,
                common = layui.common;

        upload.render({
            elem: '#file' //绑定元素
            , url: 'upload' //上传接口
            , acceptMime: '.xls,.xlsx'
            , exts: 'xls|xlsx'
            ,data: {
                type: function () {
                    var chks = document.getElementsByName("type");
                    var eqs = "";
                    for (var item in chks) {
                        if (chks[item].checked) {
                            eqs = chks[item].value
                        }
                    }
                    return eqs;
                }
            }
            , done: function (res) {
                if (res.code == 0) {
                    var index = parent.layer.getFrameIndex(window.name);
                    parent.document.getElementById('btnSearch').click();
                    parent.layer.close(index);
                }
                else {
                    common.showError(res.msg);
                }
            }
            , error: function () {
                common.showError("系统异常，请稍后再试");
            }
        });
    });
</script>
</body>
</html>